﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DTO;

namespace FastDeal
{
    public partial class TongKet : System.Web.UI.Page
    {
        private KhuyenMai_BUS khuyenMai_BUS= new KhuyenMai_BUS();
        private List<KhuyenMai> dsKhuyenMai = new List<KhuyenMai>();
        public void HienThiThongTin()
        {
            for (int i = 1; i < 13; i++)
            {
                dr_TrongThang.Items.Add(i.ToString());
            }
            dsKhuyenMai = khuyenMai_BUS.LayDanhSach_KhuyenMai();
            dr_MotKhuyenMai.DataSource = dsKhuyenMai;
            foreach (KhuyenMai km in dsKhuyenMai)
            {
                dr_MotKhuyenMai.Items.Add(km.TenKhuyenMai);
            }

            if (Panel1.Height.Value < 1000)
            {
                Panel1.Height = 1000;
            }
        }
        public double seconds;
        private DateTime GetStartTime()
        {
            return DateTime.Now;
        }
        private DateTime GetEndTime()
        {
            return new DateTime(2010, 5, 06, 8, 10, 0);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["DaDangNhap"] == null || (bool)Session["DaDangNhap"] == false)
            {
                Response.Redirect("~/Default.aspx");
            }
            if ((int)Session["LoaiThanhVien"] != 1)
            {
                Response.Redirect("~/Default.aspx");
            }
            HienThiThongTin();
            seconds = (GetEndTime() - GetStartTime()).TotalSeconds;
        }
       
        protected void dr_TrongThang_SelectedIndexChanged(object sender, EventArgs e)
        {
            int thang = int.Parse(dr_TrongThang.SelectedValue.ToString());
            Response.Redirect("WebFormDoanhThu.aspx?Thang=" + thang.ToString());
        }

        protected void dr_MotKhuyenMai_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = int.Parse(dr_MotKhuyenMai.SelectedIndex.ToString());
            KhuyenMai km = dsKhuyenMai[index];
            Response.Redirect("DoanhThuTheoKhuyenMai.aspx?MaKhuyenMai=" +km.MaKhuyenMai );
        }
    }
}